﻿@using SCMS.Resources
@model SCMS.UI.Models.ViewExpsClaims
<div class="partialViewCard">
    <div class="partialViewCardHeader">
        <h3>
            @Resources_frank.Global_String_ECF: @Model.EntityExpseRqst.RefNumber</h3>
    </div>
    @if (Model.CanEdit)
    {
        <center>
            @Ajax.ActionLink(Resources_frank.Global_String_Edit + " " + Resources_frank.Global_String_ECF, "EditECF", new AjaxOptions
       {
           UpdateTargetId = "expenseclaimDiv",
           LoadingElementId = "loading",
           Url = Url.Action("EditECF/" + Model.EntityExpseRqst.Id)
       }) |
            @Ajax.ActionLink(Resources_frank.Global_String_Delete + " " + Resources_frank.Global_String_ECF, "DeleteECF", new AjaxOptions
       {
           UpdateTargetId = "expenseclaimDiv",
           LoadingElementId = "loading",
           Url = Url.Action("DeleteECF/" + Model.EntityExpseRqst.Id),
           Confirm = "Delete '" + Model.EntityExpseRqst.RefNumber + "'?",
           OnSuccess = "usermsg('" + Resources_frank.ExpenseClaim_ViewExpsClaimsDetails_DeleteMsg + "');if (document.getElementById('table') != null) initSorter();sorter.size(50);}"
       })
        </center>
    }
    else if (Model.CanApprove)
    {
        string linkText = null;
        string actionName = null;
        if (Model.EntityExpseRqst.IsReviewed && !Model.EntityExpseRqst.IsAuthorized && !Model.EntityExpseRqst.IsRejected)
        {
            linkText = Resources_frank.ExpenseClaim_ViewExpsClaimsDetails_Authorize;
            actionName = "LoadECFForAuth";
        }
        else if (Model.EntityExpseRqst.IsSubmitted && !Model.EntityExpseRqst.IsReviewed && !Model.EntityExpseRqst.IsRejected)
        {
            linkText = Resources_frank.ExpenseClaim_ViewExpsClaimsDetails_Review;
            actionName = "ReviewECF";
        }
        if (linkText != null)
        {
            <center>
                @Ajax.ActionLink(linkText, actionName, "RequestReview", new { id = "" }, new AjaxOptions
           {
               OnBegin = "ShowDialogueOR('" + linkText + ": " + Model.EntityExpseRqst.RefNumber + "')",
               UpdateTargetId = "popup-page",
               LoadingElementId = "popup-loading",
               Url = Url.Action(actionName + "/" + Model.EntityExpseRqst.Id, "RequestReview"),
               OnSuccess = "CenterPopupECF"
           }) 
            </center>
        }
    }
    else
    {
        <br />
    }
    <table width="98%" align="center" cellspacing="0" cellpadding="0" border="1" class="cardTable">
        <tr class="gridheader">
            <th align="center">
                @Resources_frank.Global_String_Date
            </th>
            <th align="center">
                @Resources_frank.ExpenseClaim_ViewExpsClaimsDetails_Currency
            </th>
            <th align="center">
                @Resources_frank.ExpenseClaim_ViewExpsClaimsDetails_ConvertedTo
            </th>
        </tr>
        <tr class="gridodd">
            <td align="center">
                @Model.EntityExpseRqst.RequestDate.ToString("dd/MM/yyyy")
            </td>
            <td align="center">
                @Model.ExpsCurrency.ShortName
            </td>
            <td align="center">
                @Model.Converted2Currency.ShortName
            </td>
        </tr>
        <tr class="gridheader">
            <th align="center">
                @Resources_frank.ExpenseClaim_LoadExpenseClaim_ClaimBy
            </th>
            <th align="center">
                @Resources_frank.Global_String_Title
            </th>
            <th align="center">
                @Resources_frank.ExpenseClaim_ViewExpsClaimsDetails_RateOfConversion
            </th>
        </tr>
        <tr class="gridodd">
            <td align="center">
                @Model.ClaimBy.StaffName
            </td>
            <td align="center">
                @Model.ClaimBy.Designation
            </td>
            <td align="center">
                @Model.EntityExpseRqst.ExchangeRate.ToString("##,##0.00")
            </td>
        </tr>
    </table>
    <br />
    <table width="98%" align="center" cellspacing="0" cellpadding="0" border="1" class="cardTable">
        <tr class="gridheader">
            <th rowspan="2">
                @Resources_frank.Global_String_Description
            </th>
            <th colspan="3">
                @Resources_frank.ExpenseClaim_LoadExpenseClaim_Coding
            </th>
            <th colspan="2">
                @Resources_frank.Global_String_Transaction
            </th>
            <th colspan="2">
                @Resources_frank.ExpenseClaim_ViewExpsClaimsDetails_CurrencyConversion
            </th>
        </tr>
        <tr class="gridheader">
            <th>
                @Resources_frank.ExpenseClaim_ViewExpsClaimsDetails_AccountCode
            </th>
            <th>
                @Resources_frank.Budget_CategoryList_ProjectNo
            </th>
            <th>
                @Resources_frank.Budget_CreateSubLine_LineNumber
            </th>
            <th>
                @Resources_frank.Global_String_Currency
            </th>
            <th>
                @Resources_frank.Global_String_Amount
            </th>
            <th>
                @Resources_frank.ExpenseClaim_ViewExpsClaimsDetails_ExRate
            </th>
            <th>
                @Resources_frank.ExpenseClaim_ViewExpsClaimsDetails_CNVAmount
            </th>
        </tr>
        @foreach (var item in Model.ExpsItems)
        {
            <tr class="gridodd">
                <td style="width: 20%; text-align: left;">
                    @item.ItemDescription
                </td>
                <td style="width: 10%; text-align: left;">
                </td>
                <td style="width: 12%; text-align: center;">
                    @item.ProjectBudget.BudgetCategory.ProjectDonor.ProjectNumber
                </td>
                <td style="width: 12%; text-align: center;">
                    @item.ProjectBudget.LineNumber
                </td>
                <td style="width: 10%; text-align: center;">
                    @Model.ExpsCurrency.ShortName
                </td>
                <td style="width: 12%; text-align: right;">
                    @item.ItemAmount.ToString("#,##0.00")
                </td>
                <td style="width: 10%; text-align: right;">
                    @Model.EntityExpseRqst.ExchangeRate.ToString("#,##0.00")
                </td>
                <td style="width: 12%; text-align: right;">
                    @if (item.ConvertedAmount.HasValue)
                    {
                        @item.ConvertedAmount.Value.ToString("#,##0.00")
                    }
                </td>
            </tr>
        }
        <tr>
            <td colspan="2" class="gridheader">
                @Resources_frank.Global_String_MasterBudgetCurrency
            </td>
            <td align="center">
                @if (Model.EntityExpseRqst.MBCurrency.HasValue)
                { 
                    @ViewBag.MBCurrency
                }
            </td>
            <td class="gridheader" colspan="2" align="right">
                @Resources_frank.Global_String_Total
            </td>
            <td align="right">
                @if (Model.EntityExpseRqst.MBTotal.HasValue)
                { 
                    @Model.EntityExpseRqst.MBTotal.Value.ToString("#,##0.00")
                }
            </td>
            <td colspan="2" class="gridheader">
                @Resources_frank.ExpenseClaim_ViewExpsClaimsDetails_ECFValue
            </td>
        </tr>
    </table>
    <p>
    </p>
    <br />
    <table width="98%" align="center" cellspacing="0" cellpadding="0" border="1" class="cardTable">
        <tr class="gridheader">
            <td width="19%">
                @Resources_frank.Approver_ApproverList_Authorization
            </td>
            <td width="27%">
                @Resources_frank.ExpenseClaim_ViewExpsClaimsDetails_ECFSubmittedBy
            </td>
            <td width="27%">
                @Resources_frank.ExpenseClaim_ViewExpsClaimsDetails_FinanceReview
            </td>
            <td width="27%">
                @Resources_frank.ExpenseClaim_ViewExpsClaimsDetails_ECFAuthorizedBy
            </td>
        </tr>
        <tr>
            <td class="gridheader">
                @Resources_frank.Global_String_Name:
            </td>
            <td>
                @Model.PreparedBy.StaffName
            </td>
            <td>
                @if (Model.ApprovedBy != null)
                { @Model.ApprovedBy.StaffName}
            </td>
            <td>
                @if (Model.AuthorizedBy != null)
                { @Model.AuthorizedBy.StaffName}
            </td>
        </tr>
        <tr>
            <td class="gridheader">
                @Resources_frank.Global_String_Title:
            </td>
            <td>
                @Model.PreparedBy.Designation
            </td>
            <td>
                @if (Model.ApprovedBy != null)
                { @Model.ApprovedBy.Designation}
            </td>
            <td>
                @if (Model.AuthorizedBy != null)
                { @Model.AuthorizedBy.Designation}
            </td>
        </tr>
        <tr>
            <td class="gridheader">
                @Resources_frank.Global_String_Date :
            </td>
            <td>@Model.EntityExpseRqst.PreparedOn.Value.ToString("dd/MM/yyyy h:mm tt")
            </td>
            <td>
                @Html.DisplayFor(m => m.EntityExpseRqst.ReviewedOn)
            </td>
            <td>
                @Html.DisplayFor(m => m.EntityExpseRqst.AuthorizedOn)
            </td>
        </tr>
        <tr>
            <td class="gridheader">
                @Resources_frank.Global_String_Signature:
            </td>
            <td>
                @if (Model.EntityExpseRqst.Staff2 != null && Model.EntityExpseRqst.Staff2.Person.SignatureImage != null)
                { 
                    <img src="@Url.Action("Photo", "Person", new { id = Model.EntityExpseRqst.Staff2.Person.Id, area = "" })" alt="" style="max-width: 150px;" />
                }
            </td>
            <td>
                @if (Model.EntityExpseRqst.Staff3 != null && Model.EntityExpseRqst.Staff3.Person.SignatureImage != null)
                { 
                    <img src="@Url.Action("Photo", "Person", new { id = Model.EntityExpseRqst.Staff3.Person.Id, area = "" })" alt="" style="max-width: 150px;" />
                }
            </td>
            <td>
                @if (Model.EntityExpseRqst.Staff4 != null && Model.EntityExpseRqst.Staff4.Person.SignatureImage != null)
                { 
                    <img src="@Url.Action("Photo", "Person", new { id = Model.EntityExpseRqst.Staff4.Person.Id, area = "" })" alt="" style="max-width: 150px;" />
                }
            </td>
        </tr>
    </table>
    @if (Model.CanPostFunds)
    { 
        <table width="98%" align="center" cellpadding="0" cellspacing="0">
            <tr>
                <td align="right" width="100%" style="padding: 3px 0px 0px 0px">
                    <input type="button" id="btnPost" name="btnPost" value="@Resources_frank.Global_String_PostFunds" class="btn tertiary" onclick="ShowDialogue('authe'); sendRequest('/FundPosting/PostECF/@Model.EntityExpseRqst.Id', 'popup-page', 'popup-loading'); CenterPopup();" />
                    @*@Resources_frank.authe*@
                </td>
            </tr>
        </table>
    }
    else
    {    
        <br /> 
    }
    <table width="98%" align="center" cellspacing="0" cellpadding="0" border="1" class="cardTable">
        <tr class="gridheader">
            <td>
                @Resources_frank.ExpenseClaim_ViewExpsClaimsDetails_ExpenseClaim
            </td>
            <td>
                @Resources_frank.ExpenseClaim_ViewExpsClaimsDetails_SettlementPaidBy
            </td>
            <td>
                @Resources_frank.ExpenseClaim_ViewExpsClaimsDetails_SettlementReceivedBy
            </td>
            <td>
                @Resources_frank.ExpenseClaim_ViewExpsClaimsDetails_Settlement
            </td>
            <td>
                @Resources_frank.Global_String_Currency
            </td>
            <td>
                @Resources_frank.Global_String_Amount
            </td>
            <td>
                @Resources_frank.ExpenseClaim_ViewExpsClaimsDetails_ExRate
            </td>
            <td>
                @Resources_frank.ExpenseClaim_ViewExpsClaimsDetails_ConvertedAmount
            </td>
        </tr>
        <tr>
            <td class="gridheader">
                @Resources_frank.Global_String_Name:
            </td>
            <td>
                @if (Model.PostedBy != null)
                { 
                    @Model.PostedBy.StaffName
                }
            </td>
            <td>
                @if (Model.PostedBy != null && Model.ClaimBy != null)
                { 
                    @Model.ClaimBy.StaffName
                }
            </td>
            <td>
                @Resources_frank.ExpenseClaim_ViewExpsClaimsDetails_AdvReceived
            </td>
            <td>
            </td>
            <td>
            </td>
            <td>
            </td>
            <td>
            </td>
        </tr>
        <tr>
            <td class="gridheader">
                @Resources_frank.Global_String_Date:
            </td>
            <td>    
                @if (Model.EntityExpseRqst.FundsPosted)
                { 
                    @Model.EntityExpseRqst.PostedOn.Value.ToString("dd/MM/yyyy")
                }
            </td>
            <td>
                @if (Model.EntityExpseRqst.FundsPosted)
                { 
                    @Model.EntityExpseRqst.PostedOn.Value.ToString("dd/MM/yyyy")
                }
            </td>
            <td>
                @Resources_frank.ExpenseClaim_LoadExpenseClaim_TotalExpense
            </td>
            <td>
            </td>
            <td>
            </td>
            <td>
            </td>
            <td>
            </td>
        </tr>
        <tr>
            <td class="gridheader" rowspan="2">
                @Resources_frank.Global_String_Signature:
            </td>
            <td rowspan="2">
                @if (Model.EntityExpseRqst.FundsPosted)
                {
                    if (Model.EntityExpseRqst.Staff != null && Model.EntityExpseRqst.Staff.Person.SignatureImage != null)
                    { 
                    <img src="@Url.Action("Photo", "Person", new { id = Model.EntityExpseRqst.Staff.Person.Id, area = "" })" alt="" style="max-width: 150px;" />
                    }
                }
            </td>
            <td rowspan="2">
                @if (Model.EntityExpseRqst.FundsPosted)
                {
                    if (Model.EntityExpseRqst.Staff1 != null && Model.EntityExpseRqst.Staff1.Person.SignatureImage != null)
                    { 
                    <img src="@Url.Action("Photo", "Person", new { id = Model.EntityExpseRqst.Staff1.Person.Id, area = "" })" alt="" style="max-width: 150px;" />
                    }
                }
            </td>
            <td>
                @Resources_frank.ExpenseClaim_ViewExpsClaimsDetails_BalanceDue
            </td>
            <td>
            </td>
            <td>
            </td>
            <td>
            </td>
            <td>
            </td>
        </tr>
        <tr>
            <td>
                @Resources_frank.ExpenseClaim_ViewExpsClaimsDetails_SettlementPaid
            </td>
            <td>
            </td>
            <td>
            </td>
            <td>
            </td>
            <td>
            </td>
        </tr>
    </table>
    <hr />
    @if (Model.AuthorizedBy != null)
    {<a class="btn btn-primary" href="@Url.Action("pdf", "EClaim", new { area = "Reports", ECid = Model.EntityExpseRqst.Id })" target="_blank" style="margin-left: 48%; margin-bottom: 2%;">
         @Resources_frank.Budget_ViewBudget_DownloadPdf</a>}
    <br />
</div>
<br />
<p>
    @Ajax.ActionLink(Resources_frank.Global_String_BackToList, "Index", new { id = "ViewExpsClaims" }, new AjaxOptions
    {
        UpdateTargetId = "expenseclaimDiv",
        LoadingElementId = "loading",
        Url = Url.Action("ViewExpsClaims"),
        OnSuccess = "if (document.getElementById('table') != null) {initSorter();sorter.size(50);}"
    })
</p>
